package com.baizhi.springbootshiro.service.impl;

import com.baizhi.springbootshiro.entity.Perms;
import com.baizhi.springbootshiro.entity.Role;
import com.baizhi.springbootshiro.mapper.PermsMapper;
import com.baizhi.springbootshiro.service.PermsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;


/**
 * @author Administrator
 */
@Service
public class PermsServiceImpl extends ServiceImpl<PermsMapper, Perms> implements PermsService {

    @Override
    public List<Perms> getPermsByRole(Role role) {
        if (role == null) {
            return Lists.newArrayList();
        }
        return baseMapper.getPermsByRole(role);
    }

    @Override
    public List<Perms> getPermsByRoles(List<Role> roles) {
        if (CollectionUtils.isEmpty(roles)) {
            return Lists.newArrayList();
        }
        return baseMapper.getPermsByRoles(roles);
    }

    @Override
    public List<Perms> getPermsByRoleIds(List<String> roleIds) {
        if (CollectionUtils.isEmpty(roleIds)) {
            return Lists.newArrayList();
        }
        return baseMapper.getPermsByRoleIds(roleIds);
    }
}